<?php

require_once 'bcms-load.php';
/** Start Session **/
$session_db = new SessionDB();
session_set_save_handler(array(&$session_db,"open"),
        array(&$session_db,"close"),
        array(&$session_db,"read"),
        array(&$session_db,"write"),
        array(&$session_db,"destroy"),
        array(&$session_db,"gc"));

$obj_login = new Login();
if($obj_login->signon($_POST['user_name'], $_POST['user_password'])) {
    Session::set_session_user_id($_POST[user_name]);
    redirect('index.php');
}
$msg = $obj_login->get_message_code();

/*
if($_POST['user_name'] && $_POST['user_password']) {
    $user_name = trim($_POST['user_name']);
    $user_pass = trim($_POST['user_password']);

    if($user_name == 'admin' && $user_pass == 'admin') {
        session_start();
        $_SESSION['uap_user_id'] = 'admin';
        redirect('index.php');
    } else {
        $msg ='Invalid username or password';
    }
}
 * 
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Login ::: <?=bloginfo('site_name')?></title>
        <link rel="stylesheet" type="text/css" href="<?=bloginfo('template_url')?>/css/style.css" />
        <script type="text/javascript" src="<?=bloginfo('template_url')?>/js/jquery.min.js"></script>

    </head>

    <body>
        <div id="msg"><?=$msg?></div>
        <form action="#" method="post">
            <table>
                <tr>
                    <td>Username : </td>
                    <td>
                        <input type="text" id="user_name" name="user_name" />
                    </td>
                </tr>
                <tr>
                    <td>Password : </td>
                    <td>
                        <input type="password" id="user_password" name="user_password" />
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>
                        <input type="submit" value="Login" />
                    </td>
                </tr>
            </table>
        </form>

    </body>
</html>